package com.sino.tb.auditing.entity;

import java.sql.*;
import java.util.*;

public class ConfirmFlow {
	private String key;
	private String declareTypeKey;
	private String department;
	private boolean isTotalFlow;
	private int order;
	private String area;
	private int totalOrder;
	private int button;
	private String nextOrgKey;
	private int level;

	public static ConfirmFlow[] findAll(String key, Connection conn) {
		ConfirmFlow[] result = null;

		return result;

	}

	public static ConfirmFlow[] findByType(String key, Connection conn) {
		ConfirmFlow[] result = null;
		StringBuffer sql = new StringBuffer("SELECT   level, t.* ");
		sql.append("FROM     (SELECT * FROM T_ST_AUDIT_LEVEL WHERE c_type_seq = ? ) t ");
		sql.append("START WITH c_parent_id = 0 CONNECT BY PRIOR c_deptorg_id = c_parent_id ");

		try {
			PreparedStatement pstmt = conn.prepareStatement(sql.toString());
			pstmt.setString(1, key);
			ArrayList temp = new ArrayList();
			ResultSet rs = pstmt.executeQuery();
			while (rs.next()) {
				ConfirmFlow value = new ConfirmFlow();
				value.setKey(rs.getString("c_seq"));
				value.setDeclareTypeKey(rs.getString("c_type_seq"));
				value.setDepartment(rs.getString("c_deptorg_id"));
				value.setLevel(rs.getInt("level"));
				temp.add(value);
			}

			sql = null;
			if (rs != null) {
				rs.close();
			}
			if (pstmt != null) {
				pstmt.close();
			}
			result = new ConfirmFlow[temp.size()];
			ListIterator lit = temp.listIterator();
			int i = 0;
			while (lit.hasNext()) {
				result[i++] = (ConfirmFlow) lit.next();
			}
			lit = null;
			temp = null;

		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;

	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getDeclareTypeKey() {
		return declareTypeKey;
	}

	public void setDeclareTypeKey(String declareTypeKey) {
		this.declareTypeKey = declareTypeKey;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public boolean isIsTotalFlow() {
		return isTotalFlow;
	}

	public void setIsTotalFlow(boolean isTotalFlow) {
		this.isTotalFlow = isTotalFlow;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public int getTotalOrder() {
		return totalOrder;
	}

	public void setTotalOrder(int totalOrder) {
		this.totalOrder = totalOrder;
	}

	public int getButton() {
		return button;
	}

	public void setButton(int button) {
		this.button = button;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getNextOrgKey() {
		return nextOrgKey;
	}

	public void setNextOrgKey(String nextOrgKey) {
		this.nextOrgKey = nextOrgKey;
	}
}
